package prefix.exception;

public class TransactionException extends Exception {

    /**
     * 
     */
    private static final long serialVersionUID = -3684243725719757718L;

    public enum CODE {
        THIRD_STATUS_STILL_PENDING(false, true),

        INVALID_BALANCE(true, true),
        INVALID_WM_STATUS(true, true),
        INVALID_3RD_STATUS(true, true),
        INVALID_TRANSACTION_ID(true, true),
        INVALID_TRANSACTION_STATUS(true, true),
        INVALID_TYPE(true, true),
        NULL_SCHDEULE_DATE(true, true),
        TOO_EARLY_TO_EXECUTE(true, true),
        COMMIT_ERROR(true, true),
        ERROR_IN_WM(true, true),
        ERROR_IN_EXECUTE(true, true),
        ERROR_IN_ROLLBACK(true, true),
        NOT_ENOUGH_MONEY(true, true),
        NO_NEED_CREATION(false, true),
        NO_NEED_FAIL(false, true),
        INVALID_WALLET(true, true),
        NO_LOAN(true, true), 
        NO_PAYDETAIL_ATTACHED(true, true),
        NO_ORDERDETAIL(true, true);

        private boolean m_persist;

        private boolean m_alertAdmin;

        public boolean is_m_persist() {
            return m_persist;
        }

        public boolean is_m_alertAdmin() {
            return m_alertAdmin;
        }

        private CODE(boolean persist, boolean alertAdmin) {
            this.m_alertAdmin = alertAdmin;
            this.m_persist = persist;
        }
    }

    private CODE m_code;

    public TransactionException(CODE code) {
        super(code.toString());
        this.m_code = code;
    }

    public TransactionException(CODE code, Exception e, String comment) {
        super(code.toString() + " " + comment, e);
        this.m_code = code;
    }

    public TransactionException(CODE code, Exception e) {
        super(e);
        this.m_code = code;
    }

    public TransactionException(CODE code, String comment) {
        super(code.toString() + " " + comment);
        this.m_code = code;
    }

    public CODE getCode() {
        return m_code;
    }

}
